/**
 * 工具函数封装
 */

// 格式化金额
export const formatMoney = (money: number | string) => {
  const a = parseFloat(money.toString())
  return a.toLocaleString('zh-CN', { style: 'currency', currency: 'CNY' })
}

// 格式化数字
export const formatNumber = (number: number | string) => {
  const a = number.toString()
  if(a.indexOf('.') > -1) return a.replace(/(\d)(?=(\d{3})+\.)/g, '$1,')
  else return a.replace(/\d(?=(\d{3})+$)/g, '$1,')
}

